import Vue from 'vue'
import App from './App.vue'
import VueResource from 'vue-resource'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import Axios from 'axios' ;
import qs from 'qs';
import {post,fetch,patch,put} from './utils/http'
Vue.use(VueResource)



//定义全局变量
Vue.prototype.$post=post;
Vue.prototype.$fetch=fetch;
Vue.prototype.$patch=patch;
Vue.prototype.$put=put;

Vue.use(ElementUI)
Vue.use(VueResource)

Vue.config.productionTip = false

Vue.prototype.$qs = qs
Vue.prototype.$axios = Axios ;

Vue.prototype.$width = `${document.documentElement.clientWidth - 13}` + 'px' ;
Vue.prototype.$height = `${document.documentElement.clientHeight - 16}` + 'px' ;

Axios.defaults.timeout = 10000
Axios.defaults.baseURL = 'http://192.168.101.132:60000/fiction/'

Axios.defaults.headers.post['Content-Type'] = 'application/json;charset=utf-8'

Axios.interceptors.request.use(config => {    //配置axios请求头，axios每次发起请求携带token，在Network中的headers看的到
  return config
})

new Vue({
  el: '#app',
  router,
  // store,
  render: h => h(App)
})

router.beforeEach((to, from, next) => {
  if (to.path === '/') {
    next();
  } else {
    next();
  }
});

